package cn.blnp.net.flowable.other.camel;

import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

/**
 * <h3>Camel集成测试</h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/5/14 10:15
 */
@Slf4j
@SpringBootTest
public class CamelIntegrationTest {

    @Resource
    private RouteBuilder routeBuilder;
    @Resource
    private ProducerTemplate producerTemplate;
    @Resource
    private ConsumerTemplate consumerTemplate;

    @Test
    public void testRoute() throws Exception {
        CamelContext camelContext = routeBuilder.getCamelContext();
        // 发送消息到Camel路由
        producerTemplate.sendBody("direct:start", "Hello, Camel!");

        /**
         *  执行结果：
         *  2025-05-14 11:04:21.916  INFO 11620 --- [           main] Message received                         : Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello, Camel!]
         * 2025-05-14 11:04:21.917  WARN 11620 --- [           main] c.b.net.flowable.consumer.ConProcessor   : 消费取得数据：Hello, Camel!
         * 2025-05-14 11:04:21.917  WARN 11620 --- [           main] c.b.net.flowable.consumer.ConProcessor   : 消费数据请求头：{}
         **/
    }
}
